create table [Service]
( 
	 [ServiceId] int identity(1, 1) primary key
	,[ServiceName] nvarchar(128)
	,[LocationId] int
	,[Note] nvarchar(1024)
	,[CreatedBy] int
	,[CreatedDate] datetime
	,[UpdatedBy] int
	,[UpdatedDate] datetime
	,[Status] int
)
go


CREATE PROCEDURE ServiceGet
	@ServiceId int
AS
SELECT *
FROM [Service]
WHERE [Service].[ServiceId] = @ServiceId
GO

CREATE PROCEDURE ServiceList
AS
SELECT *
FROM [Service]
ORDER BY ServiceId DESC
GO

CREATE PROCEDURE ServiceInsert
	 @ServiceName nvarchar(128)
	,@LocationId int
	,@Note nvarchar(1024)
	,@CreatedBy int
	,@CreatedDate datetime
	,@UpdatedBy int
	,@UpdatedDate datetime
	,@Status int
AS

INSERT INTO [Service] (
	 [ServiceName]
	,[LocationId]
	,[Note]
	,[CreatedBy]
	,[CreatedDate]
	,[UpdatedBy]
	,[UpdatedDate]
	,[Status]
	
) VALUES (
	 @ServiceName
	,@LocationId
	,@Note
	,@CreatedBy
	,@CreatedDate
	,@UpdatedBy
	,@UpdatedDate
	,@Status
	
)

select SCOPE_IDENTITY()
GO

CREATE PROCEDURE ServiceUpdate
	@ServiceId int, 
	@ServiceName nvarchar(128), 
	@LocationId int, 
	@Note nvarchar(1024), 
	@CreatedBy int, 
	@CreatedDate datetime, 
	@UpdatedBy int, 
	@UpdatedDate datetime, 
	@Status int 

AS

UPDATE [Service] SET
	   [ServiceName] = @ServiceName
	   ,[LocationId] = @LocationId
	   ,[Note] = @Note
	   ,[CreatedBy] = @CreatedBy
	   ,[CreatedDate] = @CreatedDate
	   ,[UpdatedBy] = @UpdatedBy
	   ,[UpdatedDate] = @UpdatedDate
	   ,[Status] = @Status
WHERE [Service].[ServiceId] = @ServiceId
GO


CREATE PROCEDURE ServiceDelete
	@ServiceId int 
AS
DELETE FROM [Service]
WHERE [Service].[ServiceId] = @ServiceId
GO